package org.study.mybatis.boot.controller;

import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.study.mybatis.boot.model.Student;
import org.study.mybatis.boot.service.StudentService;

import java.util.List;

/**
 * 类的描述
 *
 * @author Administrator
 * @date 2021-05-24
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource
    private StudentService studentService;

    @RequestMapping
    public List<Student> selectAll() {
        List<Student> selectAll = studentService.selectAll();
        return selectAll;
    }

    @RequestMapping("/{id}")
    public Student selectByPrimaryKey(@PathVariable("id") Long id) {
        Student select = studentService.selectByPrimaryKey(id);
        return select;
    }

    @RequestMapping("/{pageNum}/{pageSize}")
    public PageInfo<Student> selectByPrimaryKey(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize) {
        PageInfo<Student> pageInfo = studentService.doSelectPageInfo(pageNum, pageSize);
        return pageInfo;
    }
}
